//
//  ViewController.m
//  环信即时通讯
//
//  Created by 夏阳光 on 16/4/18.
//  Copyright © 2016年 夏阳光. All rights reserved.
//

#import "ViewController.h"
#import <HyphenateFullSDK/EMSDKFull.h>

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UITextField *nameTextField;//用户名
@property (weak, nonatomic) IBOutlet UITextField *passwordTextField;//密码

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
}
- (IBAction)loginAction:(UIButton *)sender {
    
    //登录
    EMError *error = [[EMClient sharedClient] loginWithUsername:self.nameTextField.text password:self.passwordTextField.text];
    if (!error) {
        NSLog(@"登陆成功");
        
        //从数据库中获得数据
        [[EMClient sharedClient].chatManager loadAllConversationsFromDB];
        
        UINavigationController* nv=[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"FriendListNavigationController"];
        [self presentViewController:nv animated:YES completion:^{
        
        }];
    }else{
        NSLog(@"登录失败");
    }
}

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    [self.view endEditing:YES];
}





















@end
